package com.briup.cms.web.controller;

import com.briup.cms.bean.Category;
import com.briup.cms.service.ICategoryService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;
@Api(description = "栏目模块接口")
@RestController
@RequestMapping("/cms_category")
public class CategoryController {
    @Autowired
    private ICategoryService categoryService;
    @ApiOperation("查询所有栏目")
    @GetMapping("findAll")
    public  Message findAll(){
    List<Category> list=categoryService.findAll();
        return MessageUtil.success(list);
    }
    @ApiOperation("保存所需的栏目")
    @GetMapping("save")
    public Message save(Category category){
        categoryService.save(category);
        return MessageUtil.success("保存成功");
    }
    @ApiOperation("更新指定的栏目")
    @PostMapping("update")
    public Message update(Category category){
        categoryService.update(category);
        return MessageUtil.success("更新成功");
    }
    @ApiOperation("删除指定的栏目")
    @PostMapping("delete")
    public Message delete(Long id){
        categoryService.delete(id);
        return MessageUtil.success("删除成功");
    }
}
